<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title></title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" href="${baseStaticUrl}/dggui/dggui-3.0/pages/financingSC/productionDetail/productionDetail.css">
    <link rel="stylesheet" href="${baseStaticUrl}/dggui/dggui-3.0/dggplugs/hickiboss2/hickiboss2.css">
    <link rel="stylesheet" type="text/css" href="${basePath}/static/css/production.css?v=${version}"/>


</head>
<body>
<input type="hidden" value="${userEntityId}" id="userEntityId">
<input type="hidden" value="${order.id}" id="product_sc_order_id">
<input type="hidden" value="${order.orderId}" id="product_order_id">
<input type="hidden" value="${order.orderNo}" id="product_order_no">
<input type="hidden" value="${order.nodeFlowId}" id="product_node_flow_id">
<input type="hidden" value="${detailType}" id="detailType">
<div class="content-warp">
    <div class="detail-warp">
        <h3 class="detail-title">${order.scProductOrderNo}</h3>
        <table class="dggui-table-info">
            <tbody>
            <tr>
                <th>所属订单：</th>
                <td>
                    <c:if test="${empty detailType}">
                        <span>
                            <a href="javascript:void(0)" onclick="openBusinessDetail('${order.orderNo}','${order.orderId}')" class="dggui-link">${order.orderNo}</a>
                        </span>
                    </c:if>
                    <c:if test="${!empty detailType}">
                         <span>${order.orderNo}</span>
                    </c:if>

                </td>
                <th>商机编号：</th>
                <td>
                    <c:if test="${empty detailType}">
                        <span>
                            <a href="javascript:void(0)" onclick="openBusinessNoDetail('${order.businessId}','${order.businessNo}')" class="dggui-link">${order.businessNo}</a>
                        </span>
                    </c:if>
                    <c:if test="${!empty detailType}">
                        <span>${order.businessNo}</span>
                    </c:if>

                </td>
                <th >生产状态：</th>
                <td>${order.status}</td>
                <th>客户：</th>
                <td>${order.customerName}（${order.customerPhone}）
                    <c:if test="${user.id eq order.flowUserId}">
                    <d:hasUrlAuth authCode="RZSC_SHOW_PHONE">
                    <i class="iconfont icon-chaxunxinxi" style="display: inline-block;cursor:pointer; " onclick="showNumberV3('rzsc_detail','${order.customerId}','${orderPhone}')" title="查看号码"></i>
                    </d:hasUrlAuth>
                    </c:if>
                </td>
                <th>当前流程人员：</th>
                <td>${order.flowUserName}</td>
                <th>签单商务：</th>
                <td>${order.signUserName}</td>
            </tr>
            </tbody>
        </table>
        <div class="detail-btn-group">
            <c:if test="${empty detailType}">
                <d:hasUrlAuth authCode="RZSC_OPERATION_CALL">
                <a href="javascript:void(0)" class="dggui-btn" onclick="callPhoneByProduction('','${order.id}')">打电话</a>
                </d:hasUrlAuth>
                    <a href="javascript:void(0)" class="dggui-btn" onclick="remarkOrder('${order.id}')">备注</a>
                <%--待接收--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS16' || orderStauts == 'RZSCORDER_STATUS15' || orderStauts == 'RZSCORDER_STATUS01' || orderStauts == 'RZSCORDER_STATUS11'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_ORDER">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="transferOrder('${order.id}')">转单</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_WASTE_BILL">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="nullifyDetail('${order.id}')">废单</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_RECEIVE">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="receive('${order.id}')">接收</a>
                    </d:hasUrlAuth>
                </c:if>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS11'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_BACK">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="blackOrderPage('','${order.id}')">转单退回</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--办理中--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS02'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_UPDATE_NODE">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="openUpdateNode('','${order.id}','${order.scProductOrderNo}')">更新节点</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_BACK_ORDER">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="transferOrder('${order.id}')">转单</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_WASTE_BILL">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="nullifyDetail('${order.id}')">废单</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_BACK_ORDER">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="abandonDetail('${order.id}')">退单</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_PAUSE">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="suspendDetail('${order.id}')">暂缓</a>
                    </d:hasUrlAuth>
                    <%--<d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_CHANNEL">--%>
                    <%--<a href="javascript:void(0)" class="dggui-btn" onclick="updateChannel('','${order.id}')">更换渠道</a>--%>
                    <%--</d:hasUrlAuth>--%>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_ADD_ASSISTANT">
                    <a href="javascript:void(0)" class="dggui-btn" onclick="addAssist('','${order.id}')">添加协单人员</a>
                    </d:hasUrlAuth>
                    <%--<d:hasUrlAuth authCode="RZSC_OPERATION_ADD_CHANNEL">--%>
                    <%--<a href="javascript:void(0)" class="dggui-btn" onclick="addChannel('','${order.id}')">新增渠道</a>--%>
                    <%--</d:hasUrlAuth>--%>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_ADD_CHANNEL">
                        <a href="javascript:void(0)" class="dggui-btn" onclick="addProduct('','${order.id}')">新增产品</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_ADD_CHANNEL">
                        <a href="javascript:void(0)" class="dggui-btn" onclick="changeProduct('','${order.id}')">更换产品</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--退单驳回--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS09'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_START">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="hintLayer('',4,'${order.id}')">恢复办理</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--废单驳回--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS10'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_START">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="hintLayer('',5,'${order.id}')">恢复办理</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--暂缓--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS03'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_START">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="hintLayerzh('','${order.id}')">恢复办理</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--待分配--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS14'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_ALLOT">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="allocate('','${order.id}')">分配</a>
                    </d:hasUrlAuth>
                </c:if>

                <%--待审核（退单待审核、废单待审核）--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS07' || orderStauts == 'RZSCORDER_STATUS05'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_AUDITOR">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="changeAudtor('','${order.id}')">变更审核人</a>
                    </d:hasUrlAuth>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_ROLL_BACK">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="withdrawn('','${order.id}')">撤回</a>
                    </d:hasUrlAuth>
                </c:if>
               <%-- 退单待审核--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS05'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_AUDITING">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="abandonAudit('','${order.id}')">审核</a>
                    </d:hasUrlAuth>
                </c:if>
                <%--废单待审核--%>
                <c:if test="${orderStauts == 'RZSCORDER_STATUS07'}">
                    <d:hasUrlAuth authCode="RZSC_OPERATION_AUDITING">
                    <a href="javascript:void(0);" class="dggui-btn" onclick="nullifyAudit('','${order.id}')">审核</a>
                     </d:hasUrlAuth>
                </c:if>
                <a href="javascript:void(0)" class="dggui-btn" onclick="openRemark('${order.customerId}')">备注详情</a>
            </c:if>
        </div>
    </div>
    <div class="bg-warp">
        <!--申请审核记录 start-->
        <div class="dggui-panel">
            <h3>申请审核记录</h3>
            <div class="panel-main">
                <table class="dggui-table-record">
                    <tbody>
                    <c:if test="${!empty auditLogs}">
                        <c:forEach var="log" items="${auditLogs}">
                            <tr>
                                <td>${log.operaterName}</td>
                                <td>
                                    <span class="dggui-tag dggui-tag-brBlue">${log.operateType}</span>
                                </td>
                                <td>${log.operateTimeStr}</td>
                                <td class="remark"><span>备注：</span><div style="    display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width: 716px;"
                                                                        title="${log.remarks}">${log.remarks}</div></td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    </tbody>
                </table>
            </div>
        </div>
        <!--申请审核记录 end-->

        <!--业务信息 start-->
        <div class="dggui-panel">
            <h3>业务信息</h3>
            <table class="dggui-table cell-border table-form">
                <thead>
                <th>业务</th>
                <th>生产所属</th>
                <th>产品</th>
                <th>商品属性</th>
                <th>手续费</th>
                <th>渠道</th>
                <th>需求金额</th>
                <th>合同编号</th>
                </thead>
                <tbody>
                <tr>
                    <td>${order.businessTypeName}</td>
                    <td>${order.productOrgName}</td>
                    <td>${order.productName}</td>
                    <td class="line2" title="${order.goodsName}">${order.goodsName}</td>
                    <td>${order.serviceCharge}%</td>
                    <th>${order.channelName}</th>
                    <td>${order.loanAmount}元</td>
                    <td>${order.contractNo}</td>
                </tr>
                </tbody>
            </table>
        </div>
        <!--业务信息 end-->
        <!--生产数据 start-->
        <div class="dggui-panel" id="business_info">
            <h3>生产数据
                <span>订单预计完成时间：<fmt:formatDate value="${order.orderEndTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss"/></span>
                <ul class="fr node-state">
                    <li>已完成</li>
                    <li class="over-finish">超期完成</li>
                    <li class="over">已超期</li>
                    <li class="not-finish">未完成</li>
                </ul>
            </h3>
            <div class="node-list-warp">
                <ul class="node-list" >
                    <c:forEach items="${nodelist}" var="node">
                        <li style="cursor: pointer;" class="
                      <c:choose>
                    <c:when test="${node.id == nextNodeOverTime && node.nodeOpetateTime ==null}">over</c:when><%--已超期--%>
                    <c:when test="${node.nodeTimeStatus == null || '' == node.nodeTimeStatus}">not-finish</c:when><%--未完成--%>
                    <c:when test="${node.nodeTimeStatus == 'OVERDUE_STATE2'}">
                        <c:if test="${node.nodeEndTime < node.nodeOpetateTime}">over-finish</c:if><%--超期完成--%>
                    </c:when>
                     <c:when test="${node.nodeTimeStatus == 'OVERDUE_STATE1'}">
                        <c:if test="${node.nodeEndTime >= node.nodeOpetateTime}"></c:if><%--已完成--%>
                    </c:when>
                </c:choose>"
                    <c:if test="${node.name != '接单'}">
                        onclick="openUpdateNode('','${order.id}','${order.scProductOrderNo}','${node.id}')"
                    </c:if>
                        >
                            <div class="node-content">
                                <p><b>${node.name}</b></p>
                                <p>
                                    ${node.createTime}
                                </p>
                                <p>
                                    <c:if test="${node.nodeTimeStatus == 'OVERDUE_STATE2'}">超期&nbsp;${node.nodeOverdueTime}</c:if>
                                </p>
                            </div>
                        </li>
                    </c:forEach>
                </ul>
            </div>
            <div id="ytHtml">

            </div>
        </div>
        <!--生产数据 end-->
        <!--多模块 tab start-->
        <div class="dggui-tab dggui-tab-complex">
            <ul class="dggui-tab-title">
                <li class="dggui-this" onclick="changeTab(2)">底单信息</li>
                <li onclick="changeTab(1)">历史记录</li>
                <li onclick="changeTab(3)">财务信息</li>
                <li onclick="changeTab(4)">附件</li>
            </ul>
            <div class="dggui-tab-content">
            </div>
            <iframe src=""
                    id="scBaseInfoIframeId"
                    name="scBaseInfoIframeName"
                    width="100%" frameborder="0" scrolling="no" allowtransparency="yes"></iframe>
        </div>
        <!--多模块 tab end-->
    </div>
</div>
<script src="${baseStaticUrl}/dggui/dggui-3.0/dggui.all.js"></script>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script src="${baseStaticUrl}/dggui/dggui-3.0/dggplugs/hickiboss2/hickiboss2.js"></script>
<script src="${rootUrl}/static/js/rzsc/common/dealDataTool.js?v=${version}" type="text/javascript"></script>
<script src="${rootUrl}/static/js/rzsc/processingOrder/processingOrder.js?v=${version}" type="text/javascript"></script>
<script>
    dggui.use(['dialog','element','select2'],function () {
        changeTab(2);
        loadProductData();
    });

    $(function(){
        $.each($(".node-list li"),function(){
            $(this).find(':before').click(function(){

            });
            /*$(this).find('.node-content').find('p').find('b').click(function(){
                alert($(this).text());
            });*/

        })
    });
    //tab切换
    function changeTab(index) {
        $(".dggui-tab-content").html('');
        document.getElementById("scBaseInfoIframeId").style.height = "0px";//最好设置为minHeight
        var url;
        var scOrderId = $("#product_sc_order_id").val();//生产订单id
        var orderId = $("#product_order_id").val();//销售主单id
        var orderNo = $("#product_order_no").val();//销售主单编号
        var flowId = $("#product_node_flow_id").val();//节点流程id
        var detailType = $("#detailType").val();//判断是否是订单系统过来的
        if (index === 1) {//历史记录
            url = sysInfo.basePath+"/order_detail/history_index.html?scOrderId="+scOrderId+"&&flowId="+flowId+"&&detailType="+detailType;
        }else if (index === 2) {//底单信息
            url = "${bottomApiUrl}/bottom_sheet/v1/production_detail_table.html?orderId="+orderId+"&type=2";
        }else if (index === 3) {//财务信息
            url = "${orfApiUrl}/orf/payment/payment_list.html?id="+orderId;
        }else if (index === 4) {//附件
            url = sysInfo.basePath + "/order_detail/query_product_attachment_page.html?productOrderId="+scOrderId;
        }

        if(index==1 || index==4){
            $("#scBaseInfoIframeId").attr("src", "");
            $.get(url,{},function(html){
                $(".dggui-tab-content").html(html);
            },'html');
        }else{
            $("#scBaseInfoIframeId").attr("src", url);
        }

    }
    //定时器调用设置页面高度
    startInit('scBaseInfoIframeId', 700);//页面底部ifame切换
    var browserVersion = window.navigator.userAgent.toUpperCase();
    var isOpera = browserVersion.indexOf("OPERA") > -1 ? true : false;
    var isFireFox = browserVersion.indexOf("FIREFOX") > -1 ? true : false;
    var isChrome = browserVersion.indexOf("CHROME") > -1 ? true : false;
    var isSafari = browserVersion.indexOf("SAFARI") > -1 ? true : false;
    var isIE = (!!window.ActiveXObject || "ActiveXObject" in window);
    var isIE9More = (!-[1,] == false);

    //iframe自适应启动器
    function startInit(iframeId, minHeight) {
        eval("window.IE9MoreRealHeight" + iframeId + "=0");
        window.setInterval("reinitIframe('" + iframeId + "'," + minHeight + ")", 100);
    }
    //ifame自适应页面高度
    function reinitIframe(iframeId, minHeight) {
        try {
            var iframe = document.getElementById(iframeId);
            var bHeight = 0;
            if (isChrome == false && isSafari == false) {
                try {
                    bHeight = iframe.contentWindow.document.body.scrollHeight;
                } catch (ex) {
                }
            }
            var dHeight = 0;
            if (isFireFox == true)
                dHeight = iframe.contentWindow.document.documentElement.offsetHeight + 2;//如果火狐浏览器高度不断增加删除+2
            else if (isIE == false && isOpera == false && iframe.contentWindow) {
                try {
                    dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                } catch (ex) {
                }
            }
            else if (isIE == true && isIE9More) {//ie9+
                var heightDeviation = bHeight - eval("window.IE9MoreRealHeight" + iframeId);
                if (heightDeviation == 0) {
                    bHeight += 3;
                } else if (heightDeviation != 3) {
                    eval("window.IE9MoreRealHeight" + iframeId + "=" + bHeight);
                    bHeight += 3;
                }
            }
            else//ie[6-8]、OPERA
                bHeight += 3;

            var height = Math.max(bHeight, dHeight);
            if (height < minHeight) height = minHeight;
            //alert(iframe.contentWindow.document.body.scrollHeight + "~" + iframe.contentWindow.document.documentElement.scrollHeight);
            iframe.style.height = height + "px";
        } catch (ex) {
        }
    }
    //废单
    function nullifyDetail(scOrderId){
        if(isEmpty(scOrderId)){
            dggui.dialog.errors("生产订单id不能为空！");
            return false;
        }
        var arr = new Array();
        arr.push(scOrderId);
        nullifyGeneral(arr);
    }
    //退单
    function abandonDetail(scOrderId){
        if(isEmpty(scOrderId)){
            dggui.dialog.errors("生产订单id不能为空！");
            return false;
        }
        var arr = new Array();
        arr.push(scOrderId);
        abandonGeneral(arr);
    }
    //暂缓
    function suspendDetail(scOrderId){
        if(isEmpty(scOrderId)){
            dggui.dialog.errors("生产订单id不能为空！");
            return false;
        }
        var arr = new Array();
        arr.push(scOrderId);
        suspendPage(arr);
    }
    function loadProductData(){
        var url = "";
        var productCode = '${order.businessProductCode}';
        if(productCode == 'BUS_YT_DK_XYDK'){//信用贷款
            url= sysInfo.basePath+"/order_detail/order_info_xydk.html";
        }else if(productCode == 'BUS_YT_DK_DYDK'){//抵押贷款
            url= sysInfo.basePath+"/order_detail/order_info_dydk.html";
        }else if(productCode == 'BUS_YT_DK_ZJYW'){//资金业务
            url= sysInfo.basePath+"/order_detail/order_info_zjyw.html";
        }else{//BUS_YT_DK_QT 其他
            url= sysInfo.basePath+"/order_detail/order_info_qt.html";
        }
        $.post(url,{productOrderId:'${order.id}'},function(html){
            $("#ytHtml").html(html);
        },'html');
    }



    /**
     * 订单接收
     */
    function receive(id){
        var ids  = new Array();
        ids.push(id);
        var orderIds= JSON.stringify(ids);

            dggui.dialog.loading();
            $.ajax({
                type: 'POST',
                url: sysInfo.basePath + "/rzsc/processing_order/verify_old.do",
                data:{
                    id:id
                },
                success: function (res) {
                    dggui.dialog.loading('close');
                    //老数据单个接收绕过单个接收走批量接收
                    if (res.code == 0&&res.data==0) {
                        receiveBatch(orderIds);
                    }else if (res.code==0&&res.data==1) {
                        receiveSingle(id,null);
                    }else {
                        dggui.dialog.errors("流程数据错误");
                    }
                }
            });


    }
    /**
     * 订单接收
     */
    var channelIndex;
    function orderDetailReceive(id){
        if(isEmpty(id)){
            dggui.dialog.errors('请至少选择一条数据！');
            return;
        }
        dggui.dialog.loading();
        $.ajax({
            type: 'POST',
            async: false,
            url: sysInfo.basePath + "/rzsc/processing_order/receive_order.html",
            data:{
                id:id
            },
            success: function (resHtml) {
                if(resHtml.msg == null){//后台没有异常
                    channelIndex = dggui.dialog.open({
                        title:'接单',
                        content: resHtml,
                        area: '500px',
                        //弹框之后回调函数
                        success:function(layero,index){
                            dgg.dialog.relocation(channelIndex);//弹框重新布局
                            dggui.dialog.loading('close')
                        },
                        //点击确定触发
                        yes: function (index, layero) {
                        var obj=new Object();
                        var id  = $("#productOrderIdAdd").val();//当前主订单id
                          obj.id = id;
                          var typeCode=$("#typeCodeAdd .plug-in-code").val();//业务类型code
                          obj.typeCode = typeCode;
                          var productId =$("#productCodeAdd option:selected").val();//产品id
                          obj.productId = productId;
                          var goodsId = $("#goodAttributeIdAdd option:selected").val();//商品属性id
                          obj.goodsId = goodsId;
                          var channelId = $("#channelAdd option:selected").val();///渠道id
                          obj.channelId = channelId;
                          var channelName = $("#channelAdd option:selected").text();///渠道名称
                          obj.channelName = channelName;
                          var channelSubBranch=$("#channelSubBranchAdd").val().trim();//支行
                          obj.channelSubBranch = channelSubBranch;

                          if (isEmpty(id)) {
                              dggui.dialog.errors("当前主订单id缺失，请关闭弹窗再试");
                              return;
                          }
                          if(isEmpty(typeCode)){
                              dggui.dialog.tip('请选择业务类型',$("#typeCodeAddTip"),{tipsMore: true});
                              return;
                          }
                          if(isEmpty(productId)){
                              dggui.dialog.tip('请选择产品',$("#productCodeAddTip"),{tipsMore: true});
                              return;
                          }
                          if (isEmpty(goodsId)) {
                              dggui.dialog.tip('请选择商品属性',$("#goodAttributeIdAddTip"),{tipsMore: true});
                              return;
                          }

                          if(isEmpty(channelId)){
                              dggui.dialog.tip('请选择渠道',$("#channelTip"),{tipsMore: true})
                              return;
                          }

                          if(!isEmpty(channelSubBranch) && channelSubBranch.length>50){
                              dggui.dialog.tip('支行信息最多50个字',$("#channelSubBranchAdd"),{tipsMore: true})
                              return;
                          }


                          var paramsJson = JSON.stringify(obj);

                          dggui.dialog.loading();
                          $.ajax({
                              type: 'POST',
                              data: {params:paramsJson},
                              url: sysInfo.basePath+"/rzsc/processing_order/single_receive_order.do",
                              dataType: 'JSON',
                              success: function (data) {
                                  dggui.dialog.loading('close')
                                  if(data.code == 0 ){//保存成功
                                      dggui.dialog.loading('close');
                                      dggui.dialog.succeed('接收成功！');
                                      layer.close(index);//关闭弹框
                                      window.location.reload();
                                  }else{
                                      dggui.dialog.loading('close');
                                      dggui.dialog.errors(data.msg);
                                  }
                              },
                              error: function () {
                                  dggui.dialog.loading('close')
                                  dggui.dialog.errors("系统异常，请稍后再试");
                              }
                          });
                    }})//open end
                }else {
                    dggui.dialog.errors(resHtml.msg);
                    dggui.dialog.loading('close')
                }
            }//success end
        })
    }
    var contactEditForm={
        options:{
            form:'',
            saveFun:function () {

            },
            cancleFun:function () {

            }
        },
        init:function (obj,opt) {
            opt=this.options=$.extend({},this.options,opt);
            var btnHtm='<div id="'+this.options.form+'-btn"><a href="javascript:void(0)" class="dggui-btn dggui-btn-sm" onclick="contactEditForm.saveForm(this)">保存</a><a href="javascript:void(0)" class="dggui-btn dggui-btn-primary dggui-btn-sm" onclick="contactEditForm.cancleForm(this)">取消</a></div>'
            $(obj).before(btnHtm);
            $(obj).hide();
            this.dataVal(opt);
        },
        dataVal:function (opt) {
            $(opt.form).find('.edit').addClass('be-editing');
            $.each($(opt.form)[0],function (i,v) {
                var formtype=$(v)[0].type;
                if(formtype=='radio'||formtype=='checkbox') {
                    $(v).parents('td').children('p').hide();
                    $(v).parents('td').show();
                }else {
                    if($(v)[0].id == 'wayOfLoan' || $(v)[0].id == 'dateOfLoan'){
                        $("#loan_way_and_date_txt").val(joinLoanWayAndTime($("#wayOfLoan").val(),$("#dateOfLoan").val()));
                        $("#loan_way_and_date_txt").html(joinLoanWayAndTime('${order.wayOfLoan}','${order.dateOfLoan}'));
                    }else if($(v)[0].id == 'thirdpartyName' || $(v)[0].id == 'thirdpartyNumber') {
                        $("#thirdparty_name_and_number").html(joinThirdparty('${order.thirdpartyName}','${order.thirdpartyNumber}'));
                    }else{
                        $(v).parents('td').children('p').hide();
                        $(v).parents('td').children('div').show();
                        $(v).show();
                    }
                }
            })
        },
        saveForm:function (obj,id) {
            var flag = contactSaveData(obj);
            if(!flag)
                return false;
            var opt=this.options;
            opt.saveFun(opt);
            $(opt.form).find('.edit').removeClass('be-editing');
            $.each($(opt.form)[0],function (i,v) {
                var formtype=$(v)[0].type;
                if(formtype=='radio'||formtype=='checkbox') {
                    $(v).parents('td').children('p').show();
                    $(v).parents('td').hide();
                }else if(formtype=='file'){
                    return false;
                }else{
                    $(v).parents('td').children('p').show();
                    $(v).parents('td').children('div').hide();
                    $(v).hide();
                }
            });
            $(obj).parent().next().show();
            $(obj).parent().remove();
        },
        cancleForm:function (obj) {
            /*var IdCardCopy = $("#IdCardCopy").val();
            var noCopy = $("#noCopy").val();*/
            //重置身份证和电话
            var IdCardCopy = $(obj).parent().parent().parent('li').find('[name=IdCardCopy]').val();
            var noCopy = $(obj).parent().parent().parent('li').find('[name=noCopy]').val();
            /*$("#orderConcactCardId").val(IdCardCopy);
            $("#orderConcactNo").val(noCopy);*/
            $(obj).parent().parent().parent('li').find('[name=orderConcactCardId]').val(IdCardCopy);
            $(obj).parent().parent().parent('li').find('[name=orderConcactNo]').val(noCopy);
            /*$("#IdCardState").val("0");
            $("#noState").val("0");*/

            $(obj).parent().parent().parent('li').find('[name=IdCardState]').val('0');
            $(obj).parent().parent().parent('li').find('[name=noState]').val('0');

            //重置名称
            var orderConcactNameCopy = $(obj).parent().parent().parent('li').find('[name=orderConcactNameCopy]').val();
            $(obj).parent().parent().parent('li').find('[name=orderConcactName]').val(orderConcactNameCopy);

            //重置侄女个数
            var orderContactChildrenNumsCopy = $(obj).parent().parent().parent('li').find('[name=orderContactChildrenNumsCopy]').val();
            $(obj).parent().parent().parent('li').find('[name=orderConcactContactChildrenNum]').val(orderContactChildrenNumsCopy);

            //重置是否客户本人
            var orderConcactIsSelfCopy = $(obj).parent().parent().parent('li').find('[name=orderConcactIsSelfCopy]').val();
            $(obj).parent().parent().parent('li').find('[name=orderConcactIsSelf]').val(orderConcactIsSelfCopy);
            //重置婚姻状况
            /*var orderConcactMaritalStatusCopy = $(obj).parent().parent().parent('li').find('[name=orderConcactMaritalStatusCopy]').val();
            $(obj).parent().parent().parent('li').find('[name=orderConcactContactMaritalStatus]').val(orderConcactMaritalStatusCopy);*/

            //重置家属是否知晓
            var orderConcactNoKnowCopy = $(obj).parent().parent().parent('li').find('[name=orderConcactNoKnowCopy]').val();
            $(obj).parent().parent().parent('li').find('[name=orderConcactNoKnow]').val(orderConcactNoKnowCopy);

            var opt=this.options;
            opt.cancleFun(opt);
            $(opt.form).find('.edit').removeClass('be-editing');
            $.each($(opt.form)[0],function (i,v) {
                var formtype=$(v)[0].type;
                if(formtype=='radio'||formtype=='checkbox') {
                    $(v).parents('td').children('p').show();
                    $(v).parents('td').hide();
                }else if($(v)[0].id == 'wayOfLoan' || $(v)[0].id == 'dateOfLoan'){
                    $("#loan_way_and_date_txt").text(joinLoanWayAndTimeTxt($("#wayOfLoan").attr("data-old"),$("#dateOfLoan").attr("data-old")));
                }else if($(v)[0].id == 'thirdpartyName' || $(v)[0].id == 'thirdpartyNumber') {
                    var textThird = "";
                    if(checkEmpty('${order.thirdpartyNumber}')){
                        textThird = '${order.thirdpartyName}'+"/"+'${order.thirdpartyNumber}';
                    }else{
                        textThird = '${order.thirdpartyName}';
                    }
                    $("#thirdparty_name_and_number").text(textThird);
                }else if(formtype=='file'){
                    return false;
                }else {
                    //$(v).parents('td').children('p').show();
                    //$(v).parents('td').children('div').hide();
                    //$(v).hide();
                }
            });
            $.each($(obj).parent().parent().parent().find('.hide-show'),function(){
                $(this).hide();
            })
            $.each($(obj).parent().parent().parent().find('.line2'),function(){
                $(this).show();
            })
            //$(obj).parent().parent().parent().find('.hide-show').hide();
            $(obj).parent().next().show();
            $(obj).parent().remove();
        }
    }
    //保存
    function contactSaveData(obj){
        var IdCardState = $(obj).parent().parent().parent('li').find('[name=IdCardState]').val();
        var noState = $(obj).parent().parent().parent('li').find('[name=noState]').val();
        if(!verifyEmpty($(obj).parent().parent().parent('li').find('[name=orderConcactName]'),"借贷人名称不能为空"))
            return false;
        if(!verifyLength($(obj).parent().parent().parent('li').find('[name=orderConcactName]'),16,"借贷人名称不能超过16个字"))
            return false;
        if(IdCardState == 1){
            if(!verifyEmpty($(obj).parent().parent().parent('li').find('[name=orderConcactCardId]'),"身份证号码不能为空"))
                return false;
            if(!isIdCard($(obj).parent().parent().parent('li').find('[name=orderConcactCardId]'),"身份证号码格式不对")){
                /*dggui.dialog.tip("身份证号码格式不对",$(obj).parent().parent().parent('li').find('[name=orderConcactCardId]'),{tipsMore: true});*/
                return false;
            }
            if($(obj).parent().parent().parent('li').find('[name=orderConcactCardId]').val().trim().length>30){
                dggui.dialog.tip("身份证号码长度不能大于30位",$(obj).parent().parent().parent('li').find('[name=orderConcactCardId]'),{tipsMore: true});
                return false;
            }
        }
        if(noState == 1){
            if(!isTel($(obj).parent().parent().parent('li').find('[name=orderConcactNo]'),"联系电话格式不对"))
                return false;
        }
        if(!verifyEmpty($(obj).parent().parent().parent('li').find('[name=orderConcactContactChildrenNum]'),"子女情况不能为空"))
            return false;
        if(!isIntNumberTip($(obj).parent().parent().parent('li').find('[name=orderConcactContactChildrenNum]'),"请输入正确的数字"))
            return false;
        if(!verifyLength($(obj).parent().parent().parent('li').find('[name=orderConcactContactChildrenNum]'),4,"子女情况不符合实际情况"))
            return false;
        var params = serializeObject($(obj).parent().parent().parent().find('[name=orderConcactdataInfo]'));
        console.log(params);
        dggui.dialog.loading();
        $.ajax({
            type: 'POST',
            data: params,
            url: sysInfo.basePath + '/order_detail/order_contact_update.do',
            dataType: 'JSON',
            success: function (data) {
                dggui.dialog.loading('close');
                if (data.code == 0) {
                    dggui.dialog.succeed('操作成功！')
                    //刷新列表
                   window.location.reload();
                } else {
                    dggui.dialog.errors(data.msg);
                }
            },
            error: function () {
                dggui.dialog.loading('close');
                dggui.dialog.errors('保存失败，请联系管理员！！');
            }
        })
    }
    function clearClick(obj,hid,id){
        $(obj).val('');
        $(obj).parent().parent().parent().parent().parent().find('input[name='+hid+']').val('1');
        //$("#"+hid).val("1");
        //$("#"+id).val("");
    }
    function blurClick(obj,copyId,stateId){
        var copyIdVal =  $(obj).parent().parent().parent().parent().parent().find('input[name='+copyId+']').val();
        if($(obj).val().trim() == ''){
            $(obj).val(copyIdVal);
            $(obj).parent().parent().parent().parent().parent().find('input[name='+stateId+']').val('0');
        }
    }
    /**
     * 查看身份证号码
     */
    function showIdCare(contactId,scProductId){
        $.ajax({
            type: "get",
            url: sysInfo.basePath + '/order_detail/get_IdCard_by_contactId.do',
            data: {
                contactId: contactId
            },
            dataType: 'json',
            success:function(result){
                if(result.code == '0'){
                    var numberCiphertext = result.data;
                    if("" != numberCiphertext && null != numberCiphertext){
                        dggui.dialog.succeed(numberCiphertext,5*1000);
                        $.ajax({
                            type: "post",
                            url: sysInfo.basePath + "/check_record/save_check_record.do",
                            data: {
                                contactId: contactId,
                                scproductId: scProductId,
                                operaterType: '1',
                                remarks: '查看借贷人身份证号码',
                                tableName: 'rzsc_order_contact'
                            },
                            dataType: 'json',
                            success: function (data){
                                console.log(data);
                            }
                        });
                    } else {
                        dggui.dialog.errors("暂无身份证号码");
                    }
                }else{
                    dggui.dialog.errors(result.msg);
                }
            },
            error:function(error){
                dggui.dialog.errors('服务器异常，请联系管理员')
            }
        });

    }
    /**
     * 查看借贷人电话号码
     */
    function showPhone(contactId,scProductId){
        $.ajax({
            type: "get",
            url: sysInfo.basePath + '/order_detail/get_phone_by_contactId.do',
            data: {
                contactId: contactId
            },
            dataType: 'json',
            success:function(result){
                if(result.code == '0'){
                    var numberCiphertext = result.data;
                    if("" != numberCiphertext && null != numberCiphertext){
                        dggui.dialog.succeed(numberCiphertext,5*1000);
                        $.ajax({
                            type: "post",
                            url: sysInfo.basePath + "/check_record/save_check_record.do",
                            data: {
                                contactId: contactId,
                                scproductId: scProductId,
                                operaterType: '2',
                                remarks: '查看借贷人联系电话',
                                tableName: 'rzsc_order_contact'
                            },
                            dataType: 'json',
                            success: function (data){
                                console.log(data);
                            }
                        });
                    } else {
                        dggui.dialog.errors("暂无身份证号码");
                    }
                }else{
                    dggui.dialog.errors(result.msg);
                }
            },
            error:function(error){
                dggui.dialog.errors('服务器异常，请联系管理员')
            }
        });
    }

    function openRemark(customerId){
        window.parent.updateTab('备注详情',sysInfo.ucApiUrl+'/uc/new_customer_detail/get_customer_records_page.html?customerId='+customerId);
    }

</script>
</body>
</html>